//*----------------------------------------------------------------------------
//*         ATMEL Microcontroller Software Support  -  ROUSSET  -
//*----------------------------------------------------------------------------
//* The software is delivered "AS IS" without warranty or condition of any
//* kind, either express, implied or statutory. This includes without
//* limitation any warranty or condition with respect to merchantability or
//* fitness for any particular purpose, or against the infringements of
//* intellectual property rights of others.
//*----------------------------------------------------------------------------
//* File Name           : m55800.h
//* Object              : AT91M55800A Architecture Definition File
//*
//* 1.0 11/07/00  PF    : Creation
//*----------------------------------------------------------------------------

#ifndef m55800_h
#define m55800_h

/*-------------------------------------*/
/* Peripheral and Interrupt Identifier */
/*-------------------------------------*/

#define FIQ_ID      0       /* Fast Interrupt */

#define SW_ID       1       /* Soft Interrupt (generated by the AIC) */

#define US0_ID      2       /* USART Channel 0 */
#define US1_ID      3       /* USART Channel 1 */
#define US2_ID      4       /* USART Channel 2 */

#define SPI_ID      5       /* SPI Channel */

#define TC0_ID      6       /* Timer Channel 0 */
#define TC1_ID      7       /* Timer Channel 1 */
#define TC2_ID      8       /* Timer Channel 2 */
#define TC3_ID      9       /* Timer Channel 3 */
#define TC4_ID      10      /* Timer Channel 4 */
#define TC5_ID      11      /* Timer Channel 5 */

#define WD_ID       12      /* Watchdog interrupt */

#define PIOA_ID     13      /* Parallel I/O Controller A interrupt */
#define PIOB_ID     14      /* Parallel I/O Controller B interrupt */

#define AD0_ID      15      /* Analog to Digital Converter Channel 0 interrupt */
#define AD1_ID      16      /* Analog to Digital Converter Channel 1 interrupt */

#define DAC0_ID     17      /* Digital to Analog Converter Channel 0 interrupt */
#define DAC1_ID     18      /* Digital to Analog Converter Channel 1 interrupt */

#define RTC_ID      19      /* Real Time Clock interrupt */

#define APMC_ID     20      /* Advanced Power Management Controller interrupt */

#define SLCKIRQ_ID  23      /* Slow Clock Interrupt */
#define IRQ5_ID     24      /* External interrupt 5 */
#define IRQ4_ID     25      /* External interrupt 4 */
#define IRQ3_ID     26      /* External interrupt 3 */
#define IRQ2_ID     27      /* External interrupt 2 */
#define IRQ1_ID     28      /* External interrupt 1 */
#define IRQ0_ID     29      /* External interrupt 0 */

#define COMMRX_ID   30      /* RX Debug Communication Channel interrupt */
#define COMMTX_ID   31      /* TX Debug Communication Channel interrupt */

/*-----------------------*/
/* Peripheral Memory Map */
/*-----------------------*/

#define PIOB_BASE       ((StructPIO *)0xFFFF0000)       /* Parallel I/O Controller B */
#define PIOA_BASE       ((StructPIO *)0xFFFEC000)       /* Parallel I/O Controller A */


#define TCB1_BASE       ((StructTCBlock *)0xFFFD4000)   /* Channels 3, 4, 5 */
#define TCB0_BASE       ((StructTCBlock *)0xFFFD0000)   /* Channels 0, 1, 2 */

#define USART2_BASE     ((StructUSART *)0xFFFC8000)     /* USART 2 */
#define USART1_BASE     ((StructUSART *)0xFFFC4000)     /* USART 1 */
#define USART0_BASE     ((StructUSART *)0xFFFC0000)     /* USART 0 */

#define SPI_BASE        ((StructSPI *)0xFFFBC000)       /* SPI */

#define RTC_BASE        ((StructRTC *)0xFFFB8000)       /* Real Time Clock */

#define ADC1_BASE       ((StructADC *)0xFFFB4000)       /* Analog to Digital Converter 1 */
#define ADC0_BASE       ((StructADC *)0xFFFB0000)       /* Analog to Digital Converter 0 */

#define DAC1_BASE       ((StructDAC *)0xFFFAC000)       /* DAC 1 */
#define DAC0_BASE       ((StructDAC *)0xFFFA8000)       /* DAC 0 */

#define WD_BASE         ((StructWD *)0xFFFF8000)       /* WatchDog */

/*-------------------------*/
/* Internal RAM Definition */
/*-------------------------*/

#define RAM_SIZE        (8*1024)
#define RAM_BASE        ((u_int *)0x00000000)
#define RAM_LIMIT       (((u_int)RAM_BASE) + RAM_SIZE)

/* The internal RAM is mapped at address 0x00300000 after reset until
   Remap command is performed on the EBI. */

#define RAM_BASE_BOOT       ((u_int *)0x00300000)


/*-----------------------------------*/
/*  ARM Core                         */
/*-----------------------------------*/
#include    "periph/arm7tdmi/arm.h"

/*----------------------------*/
/* External Bus Interface     */
/*----------------------------*/
#include    "periph/ebi/ebi.h"

/*---------------------------------------*/
/* Advanced Power Management Controller  */
/*---------------------------------------*/
#include    "periph/power_saving/apmc55800.h"

/*---------------------------------*/
/* Advanced Interrupt Controller   */
/*---------------------------------*/
#include    "periph/aic/lib_aic.h"

/*-------------------------------*/
/* Parallel I/O Controller       */
/*-------------------------------*/
#include    "periph/pio/pioa.h"
#include    "periph/pio/piob.h"
#include    "periph/pio/lib_pio.h"

#define NB_PIOA         30          /* Number of PIO A Lines */
#define NB_PIOB         28          /* Number of PIO B Lines */

/*------------------*/
/* Pin Multiplexing */
/*------------------*/
/* PIO Controller A */
#define PIOTCLK3       0            /* Timer 3 Clock signal */
#define PIOTIOA3       1            /* Timer 3 Signal A */
#define PIOTIOB3       2            /* Timer 3 Signal B */

#define PIOTCLK4       3            /* Timer 4 Clock signal */
#define PIOTIOA4       4            /* Timer 4 Signal A */
#define PIOTIOB4       5            /* Timer 4 Signal B */

#define PIOTCLK5       6            /* Timer 5 Clock signal */
#define PIOTIOA5       7            /* Timer 5 Signal A */
#define PIOTIOB5       8            /* Timer 5 Signal B */

#define PIOIRQ0        9            /* External Interrupt 0 */
#define PIOIRQ1       10            /* External Interrupt 1 */
#define PIOIRQ2       11            /* External Interrupt 2 */
#define PIOIRQ3       12            /* External Interrupt 3 */
#define PIOFIQ        13            /* Fast Interrupt */

#define PIOSCK0       14            /* USART 0 signal */
#define PIOTXD0       15            /* USART 0 transmit data */
#define PIORXD0       16            /* USART 0 receive data  */
#define PIOSCK1       17            /* USART 1 clock signal  */
#define PIOTXD1       18            /* USART 1 transmit data */
#define PIORXD1       19            /* USART 1 receive data  */
#define PIOSCK2       20            /* USART 2 signal */
#define PIOTXD2       21            /* USART 2 transmit data */
#define PIORXD2       22            /* USART 2 receive data  */

#define PIOSPCK       23            /* SPI clock signal */
#define PIOMISO       24            /* SPI Master In Slave */
#define PIOMOSI       25            /* SPI Master Out Slave */
#define PIONPCS0      26            /* SPI Peripheral Chip Select 0 */
#define PIONSS        PIONPCS0
#define PIONPCS1      27            /* SPI Peripheral Chip Select 1 */
#define PIONPCS2      28            /* SPI Peripheral Chip Select 2 */
#define PIONPCS3      29            /* SPI Peripheral Chip Select 3 */

/*------------------*/
/* PIO Controller B */
/*------------------*/
#define PIOIRQ4       3             /* External Interrupt 4 */
#define PIOIRQ5       4             /* External Interrupt 5 */
#define PIOSLCKIRQ    5             /* External Interrupt 6 */

#define PIOAD0TRIG    6             /* ADC 0 External trigger */
#define PIOAD1TRIG    7             /* ADC 1 External trigger */

#define PIOBMS        18            /* Boot Mode Select */

#define PIOTCLK0      19            /* Timer 0 Clock signal input */
#define PIOTIOA0      20            /* Timer 0 Signal A   */
#define PIOTIOB0      21            /* Timer 0 Signal B   */

#define PIOTCLK1      22            /* Timer 1 Clock signal */
#define PIOTIOA1      23            /* Timer 1 Signal A */
#define PIOTIOB1      24            /* Timer 1 Signal B */

#define PIOTCLK2      25            /* Timer 2 Clock signal */
#define PIOTIOA2      26            /* Timer 2 Signal A */
#define PIOTIOB2      27            /* Timer 2 Signal B */

/*---------*/
/* USARTs  */
/*---------*/
/* Definition file */
#include    "periph/usart/lib_usart.h"

/*-----------------*/
/* Real Time Clock */
/*-----------------*/
/* Definition file */
#include    "periph/rtc/lib_rtc.h"

/*---------------*/
/* Timer Counter */
/*---------------*/
#include    "periph/timer_counter/lib_tc.h"

/*-----------------------------*/
/* Analog to Digital Converter */
/*-----------------------------*/
#include    "periph/adc/lib_adc.h"

/*------------------------------*/
/* Digital to Analog Converter  */
/*------------------------------*/
#include    "periph/dac/lib_dac.h"

#endif /* m55800_h */
